/**
 * Malsha 2014-11-12
 */

CSEFileUpload = new Object();

CSEFileUpload.getCenterPanel = function() {

	return formpanel = Ext.create('Ext.form.Panel', {
		title : 'Issuer Mapping With CSE File',
		bodyPadding : 20,
		autoScroll : true,
		frame : true,
		defaults : {
			labelWidth : 110,
			anchor : '65%',
		},
		items : [ {
			xtype : 'form',
			bodyBorder : false,
			frame : true,
			border : false,
			id : 'contactPerson',
			items : [ {
				xtype : 'fileuploadfield',
				name : 'file',
				id : 'filename',
				anchor : '100%',
				fieldLabel : 'CSE File',
				labelWidth : 50,
				msgTarget : 'side',
				allowBlank : false,
				buttonText : 'Browse...'
			} ],
			buttonAlign : 'right',
			buttons : [ {
				text : 'Upload',
				handler : function() {
					var form = this.up('form').getForm();
					if (form.isValid()) {
						form.submit({
							url : 'UploadCsvFile',
							waitMsg : 'Uploading your file...',
							success : function(form, action) {
								response = Ext.decode(action.response.responseText);
								if (response.success) {
									Ext.Msg.alert('File Upload', 'Succefully uploaded to the Server');
									Ext.getCmp('console').body.update("<font size=3 color=red>" + response.NotMatchISSUER, true);
									form.reset();
								}
							},
							failure : function(form, action) {
								response = Ext.decode(action.response.responseText);
								if (!response.invalidformat) {
									Ext.Msg.alert('File Upload', 'Invalid File Format');
									form.reset();
								}
								if (response.mismatch) {
									Ext.Msg.alert('File Upload', 'Please see on console');
									Ext.getCmp('console').body.update(response.Result, true);
								}
							}
						});
					}
				}
			} ]
		}, {
			xtype : 'panel',
			title : 'Console',
			width : 200,
			id : 'console',
			height : 300,
			html : '',
		} ]
	});
};